import type { DeptTypeDetailResult, DeptTypeEntityReq, DeptTypeListResult, DeptTypeOptionResult, DeptTypePageReq } from "@/api/types";
import request from "@/utils/http";

/** 创建部门类型 */
function create(data: DeptTypeEntityReq): Promise<Resp<string>> {
    return request({
        url: "/sys/deptType/create",
        method: "post",
        data,
    });
}

/** 删除部门类型 */
function remove(id: string): Promise<Resp<null>> {
    return request({
        url: "/sys/deptType/remove",
        method: "post",
        data: { id },
    });
}

/** 更新部门类型 */
function update(data: DeptTypeEntityReq): Promise<Resp<null>> {
    return request({
        url: "/sys/deptType/update",
        method: "post",
        data,
    });
}

/** 获取部门类型详情 */
function findById(id: string): Promise<Resp<DeptTypeDetailResult>> {
    return request({
        url: "/sys/deptType/findById",
        method: "get",
        params: { id },
    });
}

/** 获取部门类型分页列表 */
function page(data: DeptTypePageReq): Promise<Resp<DeptTypeListResult[]>> {
    return request({
        url: "/sys/deptType/page",
        method: "post",
        data,
    });
}

/** 获取部门选项 */
function listOptions(level: number): Promise<Resp<DeptTypeOptionResult[]>> {
    return request({
        url: "/sys/deptType/listOptions",
        method: "get",
        params: { level },
    });
}

export const deptTypeApi = {
    create,
    findById,
    listOptions,
    page,
    remove,
    update,
};
